const { frameName, frameUrl } = require('../../config')
const inquirer = require('inquirer');
const download = require('download-git-repo')
const ora = require('ora');
const spinner = ora('Loading unicorns')
const chalk = require('chalk');
module.exports = async (project, args) => {
    const res = await inquirer.prompt([
        {
            type: 'list',
            name: 'framework',
            message: '选择所需要的框架',
            choices: frameName
        }
    ])
    spinner.start()
    download(`direct:${frameUrl[res.framework]}`, project, {clone:true},  (err) => {
        if(!err){
            spinner.color = 'yellow';
            spinner.succeed('下载成功')
            console.log(chalk.blue.bgRed.bold('cd ./' + project))
            console.log(chalk.yellow.bgBlue.bold('执行 npm install' ))
            console.log(chalk.yellow.bgBlue.bold('执行 npm run dev' ))
        }else{
            spinner.fail('下载失败！请重试')
        }
    })
}